const { program } = require('commander');  

const addFormat = (value, Accumulator) => {
  console.log(value, Accumulator);
  return value;
};
program
  .description(`None example Delete traffic data within a specified period. 
                -e.g. node scripts/delete-stats-bucket-single.js -o "2021-07-25 00:00:00" -w "2021-07-25 00:00:00"`)
  .option('-s, --start <startTime>', 'add start_time', addFormat)
  .option('-e, --end <endTime>', 'add end_time', addFormat)
  .parse(process.argv)
  .action( async (option) => {
    option.startTime = option.startTime
    option.endTime = option.endTime
    await main(option.startTime, option.endTime)
  });
// 选项则使用.opts()来获取选项值
const options = program.opts();
console.log(options);

async function main() {
  console.log('123');
}

main().then(process.exit());
